package com.sixth.controller;
import com.sixth.entity.Head;
import com.sixth.entity.Link;
import com.sixth.entity.TableResult;
import com.sixth.entity.Zone;
import com.sixth.service.ZoneService;
import com.sixth.until.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: self-tui-education
 * @description:
 * @author: C
 * @create: 2022-04-19 14:42
 **/
@RestController
@RequestMapping("/home/zone")
public class ZoneController {
    @Autowired
    private ZoneService zoneService;
    //专区导航查询功能
    @PostMapping("/getAllZone/{pageNum}/{pageSize}")
    private TableResult selectAllTeacher(@PathVariable Integer pageNum, @PathVariable Integer pageSize, @RequestBody Zone zone) {
        return zoneService.selectAllzone(pageNum,pageSize,zone);
    }
    //专区航删除功能
    @PostMapping("/deleteZone")
    public CommonResult delete(@RequestBody Zone zone) {
        return zoneService.deleteFindById(zone);
    }
    //专区导航修改方法和添加方法
    @PostMapping("/addZone")
    public CommonResult editRole(@RequestBody Zone zone){
        if (zone.getId()==null){
            return zoneService.addZone(zone);
        }else {
            return zoneService.UpdateZone(zone);
        }
    }
    //专区管理修改状态
    @PostMapping("/changeStatus/{id}/{isDisable}")
    public CommonResult changeStatus(@PathVariable String id, @PathVariable Integer isDisable) {
        return zoneService.changeStatus(id,isDisable);
    }
}
